package com.spzx.cart.api;

import com.spzx.cart.domain.CartInfo;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.domain.AjaxResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

//降级工厂用来创建降级类对象
@Component
public class RemoteCartServiceFallbackFactory
        implements FallbackFactory<RemoteCartService> {
    @Override
    public RemoteCartService create(Throwable cause) {
        //创建一个降级类对象
        return new RemoteCartService() {

            @Override
            public R<List<CartInfo>> cartListByUserId(Long userId) {

                return R.fail("查询用户选中购物项列表失败");
            }

            @Override
            public R deleteCheckedCartInfo(Long userId) {
                return R.fail("删除用户选中购物项列表失败");
            }
        };
    }
}
